package com.ems.controller;

import com.alibaba.fastjson.JSONObject;
import com.ems.exception.Result;
import com.ems.exception.ResultCode;
import com.ems.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/login")
public class LoginController {

    @Autowired
    LoginService loginService;

    @RequestMapping(value = "/getUserinfo",method = RequestMethod.GET)
    public Object login(String username,String password,Integer position)
    {
        if (username != null && password != null && position != null){
            return loginService.login(username,password,position);
        }
        else {
            return Result.state(ResultCode.NULLPOINTER);
        }
    }
}
